<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户管理</title>
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="decorator" content="default"/>

	<script type="text/javascript" src="${ctxStatic}/common/jquery-2.0.0.min.js"></script>

	<script type="text/javascript" src="${ctxStatic}/bower_components/moxie.js"></script>
	<script type="text/javascript" src="${ctxStatic}/bower_components/plupload.dev.js"></script>
	<%--<script type="text/javascript" src="/static/bower_components/plupload/js/plupload.full.min.js"></script>--%>
	<script type="text/javascript" src="${ctxStatic}/bower_components/qiniu.js"></script>
	<script type="text/javascript" src="${ctxStatic}/bower_components/shopimg.js"></script>
	<script type="text/javascript" src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.js"></script>
	<script type="text/javascript" src="${ctxStatic}/ckeditor/ckeditor.js"></script>
	<link href="${ctxStatic}/common/mycss.css" rel="stylesheet" type="css">
	<script type="text/javascript">
		function passwordLevel(password) {
			var Modes = 0;
			for (i = 0; i < password.length; i++) {
				Modes |= CharMode(password.charCodeAt(i));
			}
			return bitTotal(Modes);
			//CharMode函数
			function CharMode(iN) {
				if (iN >= 48 && iN <= 57)//数字
					return 1;
				if (iN >= 65 && iN <= 90) //大写字母
					return 2;
				if ((iN >= 97 && iN <= 122) || (iN >= 65 && iN <= 90))
				//大小写
					return 4;
				else
					return 8; //特殊字符
			}
			//bitTotal函数
			function bitTotal(num) {
				modes = 0;
				for (i = 0; i < 4; i++) {
					if (num & 1) modes++;
					num >>>= 1;
				}
				return modes;
			}
		}
		$(document).ready(function() {
			$.validator.addMethod("strongPsw",function(value,element){
				if(passwordLevel(value)==1){
					return false;
				}else{
					return true
				}
			},"请输入数字+字母大小写混合密码");
			$("#no").focus();
			$("#inputForm").validate({
				rules: {
					loginName: {remote: "${ctx}/sys/user/checkLoginName?oldLoginName=" + encodeURIComponent('${user.loginName}')},
					confirmNewPassword:{
						equalTo:"#newPassword" //再次填写密码需一致
					}
				},
				messages: {
					loginName: {remote: "用户登录名已存在"},
					confirmNewPassword: {equalTo: "输入与上面相同的密码"}
				},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});

		});
		function showAgentAndCommunity(th) {
			var _name = $(th).next().html();
			if(_name=='商户'){
				showCommunityList($("#box2").val());
				showAgentList($("#box1").val());
				$("#agentDiv").show();
				//$("#communityDiv").show();
			}else{
				$("#agentDiv").hide();
				$("#communityDiv").hide();
			}
		}
		function showAgentList(citysId){
			$.ajax({
				type : "POST",
				url : "${ctx}/sys/office/showAgentListByCityId",
				data : {
					citysId : citysId
				},
				dataType : "JSON",
				success : function(data) {
					var str = "<option>请选择</option>";
					$("#agentId").html("");
					for ( var i = 0; i < data.length; i++) {
						str += "<option value='"+data[i].id+"'>" + data[i].name + "</option>";
					}
					$("#agentId").append(str);
				}
			});
		}
		function showCommunityList(areasId){
			$.ajax({
				type : "POST",
				url : "${ctx}/sys/office/showCommunityListByAreaId",
				data : {
					areasId : areasId
				},
				dataType : "JSON",
				success : function(data) {
					var str = "<option>请选择</option>";
					$("#communityId").html("");
					for ( var i = 0; i < data.length; i++) {
						str += "<option value='"+data[i].id+"'>" + data[i].name + "</option>";
					}
					$("#communityId").append(str);
				}
			});
		}
	</script>
	<script type="text/javascript">
		var isok=0;
		$(function() {
			//将省id传入后台
			$("#box").change(function() {
				var pid = $("#box").val();
				$.ajax({
					type : "POST",
					url : "${ctx}/sys/office/showCityListByPid",
					data : {
						pid : pid
					},
					dataType : "JSON",
					success : function(date) {
						var str = "<option>请选择</option>";
						$("#box1").html("");
						for ( var i = 0; i < date.length; i++) {
							str += "<option value='"+date[i].cityid+"'>" + date[i].city + "</option>";

						}
						$("#box1").append(str);
						$("#box").change(function() {
							$("#box1").val("请选择");
							$("#box2").val("请选择");
						});

					}
				});

			});

			//将城市id传入后台
			$("#box1").change(function() {
				var cid = $("#box1").val();
				$("#cityId").val($("#box1 option:selected").val());
				$("#cityName").val($("#box1 option:selected").text());
				$.ajax({
					type : "POST",
					url : "${ctx}/sys/office/showTownListByCid",
					data : {
						cid : cid
					},
					dataType : "JSON",
					success : function(date) {
						var str = "<option>请选择</option>";
						$("#box2").html("");
						for ( var i = 0; i < date.length; i++) {
							str += "<option value='"+date[i].areaid+"'>" + date[i].area + "</option>";

						}
						$("#box2").append(str);
						$("#box1").change(function() {
							$("#box2").find("option").remove();
						});

					}

				});

			});

		});
	</script>
	<script>
		$(document).ready(function () {
			$(document).on("click", "A[name='deleteImg']", function () {
				$(this).parent().remove();
			});
			//$("#value").focus();
		});
		if(${role.name=='系统管理员'}){
			$("#pca").show();
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<%--<li><a href="${ctx}/sys/user/list">用户列表</a></li>--%>
		<li class="active"><a href="${ctx}/sys/agent/tenementPackagefee">物业折算比例修改</a></li>
	</ul><br/>

	<form:form id="inputForm" modelAttribute="user" action="${ctx}/sys/agent/tenementPackagefee" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">物业折算比例:</label>
			<div class="controls">
				<form:input path="packingFee" htmlEscape="false" maxlength="50" max="1" min="0.01" type="number" class="required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="form-actions">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
		<%--	<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>--%>
		</div>
	</form:form>
</body>
</html>